package cn.edu.zafu.bigdata.x.Foo;

import java.util.HashMap;

class StudentGradeManager {
    // 使用HashMap存储学生姓名和对应的成绩
    private HashMap<String, Integer> studentGrades;

    public StudentGradeManager() {
        studentGrades = new HashMap<>();
    }

    // 添加学生成绩
    public void addStudent(String name, int grade) {
        studentGrades.put(name, grade);
    }

    // 根据学生姓名获取成绩
    public int getGrade(String name) {
        return studentGrades.getOrDefault(name, -1);
    }

    // 删除学生成绩
    public void removeStudent(String name) {
        studentGrades.remove(name);
    }
}

public class TestStudentGradeManager {
    public static void main(String[] args) {
        // 创建StudentGradeManager实例
        StudentGradeManager manager = new StudentGradeManager();

        // 添加学生成绩
        manager.addStudent("Alice", 90);
        manager.addStudent("Bob", 85);
        manager.addStudent("Charlie", 95);

        // 查询学生成绩
        System.out.println("Alice's grade: " + manager.getGrade("Alice")); // 应该输出90
        System.out.println("Bob's grade: " + manager.getGrade("Bob")); // 应该输出85
        System.out.println("Charlie's grade: " + manager.getGrade("Charlie")); // 应该输出95

        // 查询不存在的学生成绩
        System.out.println("David's grade: " + manager.getGrade("David")); // 应该输出-1

        // 删除学生成绩
        manager.removeStudent("Bob");
        System.out.println("Bob's grade after removal: " + manager.getGrade("Bob")); // 应该输出-1
    }
}
